home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEreplaceNonNumericMulti.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.7 KB  |  159 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //
  19. //  Creation Date:  July 16, 1997
  20. //  Author:     ajp
  21. //
  22. //  Procedure Name:
  23. //  AEreplaceNonNumericMulti
  24. //
  25. //  Description Name;
  26. //  Replaces the appropriate controls for a non-numeric multi
  27. //
  28. //  Input Value:
  29. //  node (name)
  30. //
  31. //  Output Value:
  32. //  None
  33. //
  34.  
  35. global proc AEreplaceNonNumericMulti(    string    $frameName,
  36.                                         string    $nodeName,
  37.                                         string    $attributeName,
  38.                                         string    $changedCommand,
  39.                                         string    $attributeTypeProc,
  40.                                         int        $elementIndexString[])
  41. {
  42.  
  43.     global int $gMaxNonNumericMultis;
  44.  
  45.     string    $plugName, $attrName, $controlName, $cmd;
  46.  
  47.     // build the changedCommand
  48.     //
  49.     string    $cc = "\"\"";
  50.     if ($changedCommand != "") {
  51.         $cc = ("("+$changedCommand+" \""+$nodeName+"\")");
  52.     }
  53.     
  54.     // The frame layout contains a single column layout.
  55.     //
  56.     string $children[] = `frameLayout -q -ca $frameName`;
  57.     string $columnName = $children[0];
  58.  
  59.     setParent $columnName;
  60.  
  61.     // hide the column while we're modifying the controls inside it
  62.     //
  63.     columnLayout -e -vis false $columnName;
  64.  
  65.     // get the number of controls currently in the columnLayout
  66.     //
  67.     string $currentControls[] = `columnLayout -q -ca $columnName`;
  68.     int $numCurrentControls = size($currentControls);
  69.     
  70.     // We don't display more than $gMaxNonNumericMultis items.
  71.     // If there are 2 more than that, then
  72.     // it is because we are displaying the "too big" message.
  73.     // Delete it...
  74.     //
  75.     if ( $numCurrentControls == $gMaxNonNumericMultis + 2 ){
  76.         deleteUI $currentControls[$gMaxNonNumericMultis]
  77.                  $currentControls[$gMaxNonNumericMultis+1];
  78.         $numCurrentControls = $gMaxNonNumericMultis;
  79.     }
  80.  
  81.     // get the number of controls needed by the new elements
  82.     //
  83.     int        $numElements = size($elementIndexString);
  84.     
  85.     // if there are more than twenty elements, clip them.
  86.     //
  87.     int $tooBig = 0;
  88.     if ( $numElements > $gMaxNonNumericMultis ){
  89.         $tooBig = $numElements - $gMaxNonNumericMultis;
  90.         $numElements = $gMaxNonNumericMultis;
  91.     }
  92.  
  93.     // if we have more elements than we have controls, we'll 
  94.     // need to build more, otherwise we'll have to delete
  95.     // the extra controls no longer needed
  96.     //
  97.     if ($numElements >= $numCurrentControls) {
  98.  
  99.         // reconnect the controls that we can
  100.         //
  101.         for ( $i = 0; $i < $numCurrentControls; $i++ ) {
  102.             if ($elementIndexString[$i] == -1) continue;
  103.             $controlName = $currentControls[$i];
  104.             $plugName = ($nodeName+"."+$attributeName+"["+$elementIndexString[$i]+"]");
  105.             $cmd = ($attributeTypeProc + " \""
  106.                     + $controlName + "\" \""
  107.                     + $plugName + "\" "
  108.                     + $cc);
  109.             eval($cmd);
  110.         }
  111.  
  112.         // and now create the extra controls that we need
  113.         //
  114.         string $newCommand = `substitute "replace" $attributeTypeProc "new"`;
  115.         for ( $i = $numCurrentControls; $i < $numElements; $i++ ) {
  116.             if ($elementIndexString[$i] == -1) continue;
  117.             $plugName = ($nodeName+"."+$attributeName+"["+$elementIndexString[$i]+"]");
  118.             $attrName = ($attributeName+"["+$elementIndexString[$i]+"]");
  119.             $cmd = ($newCommand + " \""
  120.                     + $plugName + "\" \""
  121.                     + $attrName + "\" "
  122.                     + $cc);
  123.             eval($cmd);
  124.         }
  125.  
  126.     } else {
  127.  
  128.         // reconnect the controls that we can
  129.         //
  130.         for ( $i = 0; $i < $numElements; $i++ ) {
  131.             if ($elementIndexString[$i] == -1) continue;
  132.             $controlName = $currentControls[$i];
  133.             $plugName = ($nodeName+"."+$attributeName+"["+$elementIndexString[$i]+"]");
  134.             $cmd = ($attributeTypeProc + " \""
  135.                     + $controlName + "\" \""
  136.                     + $plugName + "\" "
  137.                     + $cc);
  138.             eval($cmd);
  139.         }
  140.  
  141.         // and delete the extra controls
  142.         //
  143.         for ( $i = $numElements; $i < $numCurrentControls; $i++ ) {
  144.             deleteUI $currentControls[$i];
  145.         }
  146.  
  147.     }
  148.     
  149.     // if there are elements that we cannot display, tell the user
  150.     //
  151.     if ( $tooBig > 0 ){
  152.         text -l "There is insufficient room to display";
  153.         text -l ("the remaining "+$tooBig+" array items");
  154.     }
  155.  
  156.     columnLayout -e -vis true $columnName;
  157.  
  158. }
  159.